#!/usr/bin/env python

def sum_array(nums, start, end):
    if start + 1 == end:
        return nums[start] + nums[end]
    elif start == end:
        return nums[start]
    else:
        mid = start + (end - start) // 2
        return sum_array(nums, start, mid) + sum_array(nums, mid + 1, end)

def max_array(nums, start, end):
    if start == end:
        return nums[start]
    else:
        mid = start + (end - end) // 2
        return max(max_array(nums, start, mid),
                   max_array(nums, mid + 1, end))

if __name__ == "__main__":
    import random

    nums = [random.randint(0, 100) for _ in range(20)]

    print(sum(nums))
    print(sum_array(nums, 0, len(nums) - 1))